﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Framework.Plugin
{
    public class CMSHost : ICMSHost
    {
        #region Ctor

        public CMSHost()
        {
            Plugins = new List<ICMSPlugin>();
            EventsAggregator = new CMSEventsAggregator();
            pluginServices = new Dictionary<Type, ICMSService>();
        }

        #endregion

        #region Implement ICMSHost interface

        public IEnumerable<ICMSPlugin> Plugins
        {
            get;
            protected set;
        }

        public CMSEventsAggregator EventsAggregator
        {
            get;
            protected set;
        }

        public void RegisterPluginService<T>(T pluginService) where T : ICMSService
        {
            if (pluginServices.ContainsKey(typeof(T)))
            {
                pluginServices[typeof(T)] = pluginService;
            }
            else
            {
                pluginServices.Add(typeof(T), pluginService);
            }
        }

        public void Initialize()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region Implement IServiceProvider

        public object GetService(Type serviceType)
        {
            throw new NotImplementedException();
        }

        public T GetService<T>() where T : ICMSService
        {
            throw new NotImplementedException();
        }

        #endregion

        #region Fields

        protected IDictionary<Type,ICMSService> pluginServices;

        #endregion

        #region Properties

        #endregion

    }
}
